﻿<UserControl 
    xmlns:local="clr-namespace:Acme.MVVM"
    x:Class="Acme.MVVM.EventEditView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d" d:DesignHeight="365" d:DesignWidth="547">
    <UserControl.Resources>
        <Style TargetType="Label">
            <Setter Property="Margin" Value="6" />
        </Style>
        <Style TargetType="TextBox">
            <Setter Property="Margin" Value="6" />
        </Style>
        <Style TargetType="DatePicker">
            <Setter Property="Margin" Value="6" />
        </Style>
        <Style TargetType="Button">
            <Setter Property="Margin" Value="6" />
            <Setter Property="HorizontalAlignment" Value="Left"/>
            <Setter Property="VerticalAlignment" Value="Top"/>
            <Setter Property="Width" Value="75" />
            <Setter Property="Height" Value="23" />
        </Style>
    </UserControl.Resources>
    <Border BorderBrush="LightGray" BorderThickness="1" CornerRadius="10">
        <Grid d:DataContext="{d:DesignInstance local:MainWindowViewModel}">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Label Content="Title" />
            <Label Content="Date" Grid.Row="2" />
            <Label Content="Location" Grid.Row="1" />
            <Label Content="Notes" Grid.Row="3" />
            <TextBox Grid.Column="1" Text="{Binding Path=ActiveEvent.Title, Mode=TwoWay}" />
            <TextBox Grid.Column="1" Grid.Row="1" Text="{Binding Path=ActiveEvent.Location, Mode=TwoWay}"/>
            <DatePicker Grid.Column="1" Grid.Row="2" Text="{Binding Path=ActiveEvent.EventDate, Mode=TwoWay}"/>
            <TextBox AcceptsReturn="True" VerticalScrollBarVisibility="Visible" Grid.Column="1" Grid.Row="3" Height="50" Text="{Binding Path=ActiveEvent.Notes, Mode=TwoWay}"/>

            <DataGrid AutoGenerateColumns="False" Margin="6" AlternationCount="2" Grid.Column="1" Grid.Row="4" ItemsSource="{Binding Path=ActiveEvent.Expenses}">
                <DataGrid.Columns>
                    <DataGridTextColumn Binding="{Binding Recipient}" Header="Recipient" Width="100" />
                    <DataGridTextColumn Binding="{Binding Cost, StringFormat=\{0:c\}}" Width="75" Header="Cost" />
                    <DataGridTextColumn Binding="{Binding Description}" Header="Description" />
                </DataGrid.Columns>
            </DataGrid>
            <!--Token: Buttons-->
            <StackPanel Orientation="Horizontal" Grid.Row="5" Grid.ColumnSpan="2">
                <Button Content="New" Command="{Binding Path=NewCommand}" />
                <Button Content="Save" Command="{Binding Path=SaveCommand}" />
                <Button Content="Cancel" Command="{Binding Path=CancelCommand}" />
                <Button Content="Delete" Command="{Binding Path=DeleteCommand}" />
                <Button Content="Throw" Command="{Binding Path=ThrowCommand}" />
            </StackPanel>
        </Grid>
    </Border>
</UserControl>
